/*
 * Copyright (C) 2005, Velocityme Partnership
 * GanttChartData.java
 *
 * Created on 23 October 2005, 09:23
 */

package com.velocityme.www.utility;

import com.velocityme.www.dto.GanttChartDTO;
import de.laures.cewolf.DatasetProducer;
import de.laures.cewolf.links.CategoryItemLinkGenerator;
import de.laures.cewolf.tooltips.CategoryToolTipGenerator;
import java.io.Serializable;
import java.util.Map;
import org.jfree.data.category.DefaultIntervalCategoryDataset;

/**
 *
 * @author  Robert
 */
public class GanttChartData implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable {
    
    /** Creates a new instance of GanttChartData */
    public GanttChartData() {
    }
    
    public Object produceDataset(Map params) throws de.laures.cewolf.DatasetProduceException {
        GanttChartDTO ganttChartDTO = (GanttChartDTO)params.get("ganttChartDTO");
/*        DefaultIntervalCategoryDataset dataset = new DefaultIntervalCategoryDataset(ganttChartDTO.getSeriesKeys(),
                                                                                    ganttChartDTO.getCategoryKeys(),
                                                                                    ganttChartDTO.getStarts(),
                                                                                    ganttChartDTO.getEnds()) {*/
        DefaultIntervalCategoryDataset dataset = new DefaultGanttCategoryDataset(ganttChartDTO.getSeriesKeys(),
                                                                                 ganttChartDTO.getCategoryKeys(),
                                                                                 ganttChartDTO.getStarts(),
                                                                                 ganttChartDTO.getEnds(),
                                                                                 ganttChartDTO.getPercents()) {
            /**
             * @see java.lang.Object#finalize()
             */
            protected void finalize() throws Throwable {
                super.finalize();
            }
        };
        return dataset;
    }

    public String getProducerId() {
        return "GanttChartData DatasetProducer";
    }

    public boolean hasExpired(java.util.Map params, java.util.Date since) {
        return (System.currentTimeMillis() - since.getTime())  > 5000;
    }
    
    public String generateLink(Object dataset, int series, Object category) {
        return "series";
    }
    
    public String generateToolTip(org.jfree.data.category.CategoryDataset data, int series, int item) {
	return "seriesNames[series]";
    }
    
}
